﻿<%@ WebHandler Language="C#" Class="DxUserValide" %>

using System;
using System.Web;
using System.Web.SessionState;

public class DxUserValide : IHttpHandler, IRequiresSessionState
{
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
    
    /// <summary>
    /// 用户单点登录校验
    /// </summary>
    /// <param name="context"></param>
    public void ProcessRequest(HttpContext context)
    {
        string strReturn = string.Empty;

        try
        {
            //从url获取认证code
            String strAppId = context.Request["AppId"];
            String strUserId = context.Request["UserId"];
            String strPass = context.Request["Password"];
            String strRetUrl = context.Request["RetUrl"];

            //验证是否是管理员
            bool bReturn = ChBusiness.User.UserHandle.ValidateUser(strUserId, strPass);
            if (bReturn)
            {
                
                
                HttpContext.Current.Session["title"] = "国家测绘地理信息局行政许可在线审批系统";
                HttpContext.Current.Session.Remove("Menu");

                //对预审标志初始化
                HttpContext.Current.Session["PromiseFlag"] = string.Empty;
                HttpContext.Current.Session["UserID"] = strUserId;
                string strUserName = ChBusiness.User.UserHandle.GetNotes(strUserId);

                if (!string.IsNullOrEmpty(strUserName))
                {
                    HttpContext.Current.Session["LoginUserName"] = strUserName;
                    strRetUrl += "&appid=" + strAppId;
                    context.Response.Redirect(strRetUrl);
                }
                else
                {
                    string strScript = string.Format("<script>alert('{0}用户在业务系统中不存在')</script>", strUserId);
                    context.Response.Write(strScript);
                }        
            }
            else
            {
                string strScript = "<script>alert('用户名和密码验证错误！')</script>";
                context.Response.Write(strScript);
            }
        }
        catch (Exception ex)
        {
            Common.Log.LogManage.addLogErr("valide", ex.Message);
        }
    }

}